package cn.qingxuntech.console.controller

import cn.qingxuntech.console.entity.LogRecord
import cn.qingxuntech.console.entity.SspSpace
import cn.qingxuntech.console.model.R
import cn.qingxuntech.console.model.request.SspSpaceRequest
import cn.qingxuntech.console.service.LogRecordService
import cn.qingxuntech.console.service.SspSpaceService
import com.mybatisflex.core.paginate.Page
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/qx/console/v1/space")
class SspSpaceController {

    @Autowired
    lateinit var sspSpaceService: SspSpaceService

    @Autowired
    lateinit var logRecordService: LogRecordService



    @PostMapping("/list")
    fun list(@RequestBody sspSpaceRequest: SspSpaceRequest): R<List<SspSpace>> {
        return R.success(sspSpaceService.list(sspSpaceRequest))
    }

    @PostMapping("/page")
    fun page(@RequestBody sspSpaceRequest: SspSpaceRequest): R<Page<SspSpace>> {

        return R.success(sspSpaceService.page(sspSpaceRequest))
    }

    @PostMapping("last10Records")
    fun last10Records(@RequestBody logRecord: LogRecord): R<List<LogRecord>> {

        return R.success(logRecordService.last10Records(logRecord))
    }

}